#include <bits/stdc++.h>
#define int long long
using namespace std;
int t;
int n,m,L,V,ans;
int d[100020];
int a[100020];
int v[100020];
int p[100020];
struct range
{
	int l,r;
	range(int l=0,int r=0):l(l),r(r){}
	bool operator < (const range a) const
	{
		return r<a.r;
	}
};
range r[100020];int tot;
void initialize()
{
	tot=ans=0;
}
inline long double calc(int v0,int a,long double t){return v0*t+1.0L*a*t*t/2;}
void solve()
{
	scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
	initialize();
	for(int i=1;i<=n;i++) scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
	for(int i=1;i<=m;i++) scanf("%lld",&p[i]);
	for(int i=1;i<=n;i++)
	{
		if(d[i]>p[m]) continue;
		if(a[i]==0)
		{
			if(v[i]>V)
			{
				if(d[i]<=p[m]) r[++tot]=range(lower_bound(p+1,p+m+1,d[i])-p,m);
			}
		}
		if(a[i]>0)
		{
			if(v[i]>V) r[++tot]=range(lower_bound(p+1,p+m+1,d[i])-p,m);
			else
			{
				int pos=ceill(calc(v[i],a[i],1.0*(V-v[i])/a[i])+1e-9L)+0.5L;
				pos+=d[i];
				//~ if(pos==p[m])
				//~ {
					//~ printf("d=%lld v=%lld a=%lld\n",d[i],v[i],a[i]);
					//~ printf("%.5Lf\n",calc(v[i],a[i],1.0*(V-v[i])/a[i]));
				//~ }
				if(pos<=p[m])
				{
					r[++tot]=range(lower_bound(p+1,p+m+1,pos)-p,m);
				}
			}
		}
		if(a[i]<0)
		{
			if(v[i]>V)
			{
				int pos=floorl(calc(v[i],a[i],1.0*(V-v[i])/a[i])-1e-9L)+0.5L;
				pos+=d[i];
				int l=lower_bound(p+1,p+m+1,d[i])-p;
				int r=upper_bound(p+1,p+m+1,pos)-p;
				if(l<r) ::r[++tot]=range(l,r-1);
			}
		}
		//~ printf("tot=%lld l=%lld r=%lld\n",tot,r[tot].l,r[tot].r);
	}
	sort(r+1,r+tot+1);
	for(int i=1,R=0;i<=tot;i++)
	{
		if(r[i].l<=R) continue;
		ans++;
		R=r[i].r;
	}
	printf("%lld %lld\n",tot,m-ans);
}
signed main()
{
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	cin>>t;
	while(t--) solve();
	return 0;
}
